iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 19
0
Blockchain

30天30個Smart contract 系列 第 19

Day18-Decentralize Exchange (1/2)

  • 分享至 

  • xImage
  •  

導言

待補充....

程式碼

pragma solidity^0.4.25;

library SafeMath{
    function add(uint a, uint b) internal pure returns (uint c) {
        c = a + b;
        require(c >= a);
    }
    function sub(uint a, uint b) internal pure returns (uint c) {
        require(b <= a);
        c = a - b;
    }
    function mul(uint a, uint b) internal pure returns (uint c) {
        c = a * b;
        require(a == 0 || c / a == b);
    }
    function div(uint a, uint b) internal pure returns (uint c) {
        require(b > 0);
        c = a / b;
    }
}
contract Exchange{
    using SafeMath for uint256;
    
    mapping (address => mapping (address => uint256)) tokenLedger;
    mapping (address => uint256) lastActiveTx;
    address public feeAddress;

    event Deposit(address indexed tokenAddress, address indexed user, uint256 amount, uint256 balance);
    event Withdraw(address indexed tokenAddress, address indexed user, uint256 amount, uint256 balance);
    
    
    modifier onlyOwner{
        require(msg.sender == owner);
        _;
    }
    
    constructor() {
        owner = msg.sender;
    }
    
}

解說

(待補)


上一篇
Day17-BlindAuction
下一篇
Day19-Decentralize Exchange(2/2)
系列文
30天30個Smart contract 20
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言